package com.cross.sax;

import java.io.IOException;
import java.io.InputStream;

public class FliterInputStream extends InputStream {

	private InputStream is = null;
	private Replacer replacer = null;

	public FliterInputStream(InputStream is, Replacer replacer) {
		this.is = is;
		this.replacer = replacer;
	}

	@Override
	public int read() throws IOException {
		return is.read();
	}
	@Override
	public int read(byte buffer[], int start, int end) throws IOException {
		int a = is.read(buffer, start, end);
		buffer = replacer.replace(buffer, start, a);
		return buffer.length;
	}
	@Override
	public int available() throws IOException {
		return is.available();
	}
	@Override
	public void close() throws IOException {
		is.close();
	}
	@Override
	public synchronized void mark(int i) {
		is.mark(i);
	}
	@Override
	public synchronized void reset() throws IOException {
		is.reset();
	}
	@Override
	public boolean markSupported() {
		return is.markSupported();
	}
}
